<template>
	<view class="container">
	
		

		<uni-section title="当前拥有:" type="line" >
				<uni-card title="代扔券"":thumbnail="avatar" @click="onClick">
		价值:{{names1}}
				</uni-card>
			</uni-section>
			<uni-section title="当前拥有:" type="line" >
					<uni-card title="代扔券"":thumbnail="avatar" @click="onClick">
			价值:{{this.names2}}
					</uni-card>
				</uni-section>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				names:[],
				names1:'',
				names2:'',
				couponNames: [], // 用于保存优惠券名称的数组
				id:'',
				user:[],
				cover: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
				avatar: '/static/1.png',
				extraIcon:{
					color: '#4cd964',
					size: '22',
					type: 'gear-filled'
				}
			}
		},
		mounted() {
		
			
			//全局变量用户ID
		
			this.user = uni.getStorageSync('user');
			//this.userName = uni.getStorageSync('user.name');
			console.log('55588', this.user.id)
	
			  this.fetchData()
		
			//this.address();
		},
		methods: {
			fetchData(){
				const id=this.user.id
			uni.request({
				  url: 'http://43.136.172.73/api/v1/coupon/load_coupon',
				  method: 'GET',
				  data: { 
				  userId:this.user.id,//给后端给的phone
				  },
				  header: {
				    'Content-Type': 'application/json',
				    'Content-Type': 'application/x-www-form-urlencoded',
				    'Authorization': 'sfsdf'
				  },
				  success: (res) => {
				console.log(res)
			
				const resData = res.data.data; // 获取返回数据中的data对象
				const names = []; // 定义一个空数组用于保存名字
				
				for (let i = 0; i < resData.length; i++) {
				  const item = resData[i];
				
				  
				    names.push(item.name);
				  }
				this.names1=names[0]
				this.names2=names[1]
				
				console.log('77',names[1]); // 输出保存的名字数组
				  },
				  fail: (err) => {
				    console.error('Error:', err)
				  }
				})	
			},
			
			
			onClick(e){
				console.log(e)
			},
			actionsClick(text){
				uni.showToast({
					title:text,
					icon:'none'
				})
			}
		}
	}
</script>

<style lang="scss">

	.container {
		overflow: hidden;
	}

	.custom-cover {
		flex: 1;
		flex-direction: row;
		position: relative;
	}

	.cover-content {
		position: absolute;
		bottom: 0;
		left: 0;
		right: 0;
		height: 40px;
		background-color: rgba($color: #000000, $alpha: 0.4);
		display: flex;
		flex-direction: row;
		align-items: center;
		padding-left: 15px;
		font-size: 14px;
		color: #fff;
	}

	.card-actions {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		height: 45px;
		border-top: 1px #eee solid;
	}
	.card-actions-item {
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.card-actions-item-text {
		font-size: 12px;
		color: #666;
		margin-left: 5px;
	}
	.cover-image {
		flex: 1;
		height: 150px;
	}
	.no-border {
		border-width: 0;
	}
</style>
